package com.cyurs.netty.nettySimple.Http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @Author: Cyrus
 * @CreateDate: 2020/11/22
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        //向管道加入处理器
        ChannelPipeline pipeline = ch.pipeline();
        //HttpServerCodec是netty提供的http的编码/解码器
        pipeline.addLast("MyHttpServerCodec", new HttpServerCodec());
        //添加自定义Handler
        pipeline.addLast("MyTestHttpServerHandler", new TestHttpServerHandler());
    }
}
